var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		id : 'paging',
		l_column : [ {
			colkey : "id",
			name : "id",
			width : "50px",
			hide : true
		}, {
			colkey : "openid",
			hide : true,
			name : "微信ID"
		}, {
			colkey : "nickname",
			name : "昵称"
		}, {
			colkey : "zjdj",
			name : "中奖类型"
		}, {
			colkey : "jp",
			name : "奖品"
		}, {
			colkey : "createTime",
			name : "中奖时间",
			renderData : function(rowindex, data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		}, {
			colkey : "status",
			name : "兑奖状态",
			renderData : function(rowindex, data, rowdata, column) {
				if ("1" == data) {
					return "未兑奖"
				} else if ("2" == data) {
					return " 已兑奖"
				} else {
					return "未验证";
				}
			}
		}, {
			colkey : "mobile",
			name : "手机号"
		} ],
		jsonUrl : rootPath + '/winuser/findByPage.shtml',
		checkbox : true
	});
	$("#searchForm").click("click", function() {// 绑定查询按扭
		var searchParams = $("#fenye").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	$("#typeFun").click("click", function() {
		typeFun();
	});
});

function typeFun() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}

	layer.confirm('是否确认兑换？', function(index) {
		var url = rootPath + '/winuser/openEntity.shtml?id=' + cbox;
		var s = CommnUtil.ajax(url, "", "json");
		if (s == "success") {
			layer.msg('确认成功');
			grid.loadData();
		} else {
			layer.msg('确认失败');
		}
	});
}
